package cn.cjxy.userms.controller;

import cn.cjxy.userms.service.UserService;
import cn.cjxy.userms.service.impl.UserServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 删除的实现
 */
@WebServlet("/deleleById")
public class DeleteServlet extends HttpServlet {
        UserService userService=new UserServiceImpl();
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //获取id
        int id = Integer.parseInt(req.getParameter("id"));
        //执行删除
        userService.deleteUser(id);
        //到列表页再次查询
        resp.sendRedirect("/list");
    }
}
